<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head lang="en">
    <meta charset="UTF-8">
    <base href="${pageContext.request.contextPath}/">
    <title>超市账单管理系统</title>
    <link rel="stylesheet" href="css/public.css"/>
    <link rel="stylesheet" href="css/style.css"/>
    <script type="text/javascript" src="js/jQuery-1.8.3.js"></script>
   <script type="text/javascript">
$(function(){
	$(".userView").on("click",function(){
	var obj = $(this);
	$.ajax({
		url:"user/userView.csdd",
		data:{"id":obj.attr("userid")},
		dataType:"json",
		success:function(data){
			if(data=="failed"){
				alert("操作超时");
			}else if("nodata"==data){
				alert("没有数据!");
			}else{
				$("#v_userCode").val(data.userCode);
				$("#v_userName").val(data.userName);
				if(data.gender==1){
					$("#v_gender").val("女");
				}else{
					$("#v_gender").val("男");
				}
				$("#v_birthday").val(data.birthday);
				$("#v_phone").val(data.phone);
				$("#v_address").val(data.address);
				if(data.userRole==1){
					$("#v_userRoleName").val("系统管理员");
				}else if(data.userRole==2){
					$("#v_userRoleName").val("经理");
				}else{
					$("#v_userRoleName").val("普通员工");
				}
			}
		},
	error:function(data){
		alert("error!");
	}
});
/* 关闭a标记的提交 */
/* return false; */
});
});
</script>
</head>
<body>
<%@include file="top.jsp" %>
<!--主体内容-->
    <section class="publicMian ">
        <%@include file="head.jsp" %>
        <div class="right">
            <div class="location">
                <strong>你现在所在的位置是:</strong>
                <span>用户管理</span>
            </div>
            <div class="search">
            <form action="user/userListshow.csdd">
                <span>用户名：</span>
                <input type="text" name="username" value="${username }" placeholder="请输入用户名"/>
                 <span>职位：</span>
                <select name="roleid" >
                    <option value="">--请选择--</option>
                    <c:forEach items="${rolelist }" var="role">
                    <option value="${role.id }" <c:if test="${roleid==role.id }">selected</c:if> >${role.roleName }</option>
                    </c:forEach>
                </select>
                <input type="submit" value="查询"/>
                </form>
                <a href="user/Adduser.csdd">添加用户</a>
            </div>
            <!--用户-->
            <table class="providerTable" cellpadding="0" cellspacing="0">
                <tr class="firstTr">
                    <th width="10%">用户编码</th>
                    <th width="20%">用户名</th>
                    <th width="10%">性别</th>
                    <th width="10%">年龄</th>
                    <th width="10%">电话</th>
                    <th width="10%">用户类型</th>
                    <th width="30%">操作</th>
                </tr>
                <c:forEach items="${userpage.datas }" var="user" >
				 <tr class="viewUser" >
                    <td>${user.userCode }</td>
                    <td>${user.userName }</td>
                    <td>
                    <c:choose>
                    <c:when test="${user.gender==2 }">
                    	男
                    </c:when>
                    <c:otherwise>女</c:otherwise>
                    </c:choose>
                    </td>
                    <td>${user.age }</td>
                    <td>${user.phone }</td>
                    <td>${user.userRoleName }</td>
                    <td>
                    <!-- user/userView.csdd?id=${user.id} -->
                        <a  ><img class="userView" userid="${user.id}"  src="img/read.png" alt="查看" title="查看"/></a>
                        <a href="user/userupdateshow-${user.id}.csdd"><img src="img/xiugai.png" alt="修改" title="修改"/></a>
                        <a href="user/userdel/${user.id}.csdd" class="removeUser"><img src="img/schu.png" alt="删除" title="删除"/></a>
                    </td>
                </tr>
                </c:forEach>
            </table>
            <!-- 分页 -->
            <c:if test="${ userpage.pageNo!=1}">
        <a href="user/userListshow.csdd?pagenum=1&username=${username}&roleid=${roleid}">首页</a>
        </c:if>
            <c:if test="${ userpage.pageNo>1}">
        <a href="user/userListshow.csdd?pagenum=${userpage.pageNo - 1}&username=${username}&roleid=${roleid}">上一页</a>
        </c:if>
        
        ${userpage.pageNo }/${userpage.pageNums}
        <c:if test="${userpage.pageNums > userpage.pageNo}">
        <a href="user/userListshow.csdd?pagenum=${userpage.pageNo + 1}&username=${username}&roleid=${roleid}">下一页</a>
        </c:if>
        <c:if test="${ userpage.pageNo!=userpage.pageNums}">
        <a href="user/userListshow.csdd?pagenum=${userpage.pageNums}&username=${username}&roleid=${roleid}">最后一页</a>
        </c:if>
        </div>
        
        
        
    </section>
    <div>
        <div>
        <label>用户编码：</label>
        <input type="text" id="v_userCode" value="" readonly="readonly" >
        </div>
        <div>
        <label>用户名称：</label>
        <input type="text" id="v_userName" value="" readonly="readonly" >
        </div>
        <div>
        <label>用户性别：</label>
        <input type="text" id="v_gender" value="" readonly="readonly" >
        </div>
        <div>
        <label>出生日期：</label>
        <input type="text" id="v_birthday" value="" readonly="readonly" >
        </div>
        <div>
        <label>用户电话：</label>
        <input type="text" id="v_phone" value="" readonly="readonly" >
        </div>
        <div>
        <label>用户角色：</label>
        <input type="text" id="v_userRoleName" value="" readonly="readonly" >
        </div>
        <div>
        <label>用户地址：</label>
        <input type="text" id="v_address" value="" readonly="readonly" >
        </div>
        </div>

<!--点击删除按钮后弹出的页面-->
<div class="zhezhao"></div>
<div class="remove" id="removeUse">
    <div class="removerChid">
        <h2>提示</h2>
        <div class="removeMain">
            <p>你确定要删除该用户吗？</p>
            <a href="#" id="yes">确定</a>
            <a href="#" id="no">取消</a>
        </div>
    </div>
</div>

    <footer class="footer">
        版权归北大青鸟
    </footer>

<script src="js/jquery.js"></script>
<!-- <script src="js/js.js"></script> -->
<script src="js/time.js"></script>
<!-- 删除标记的弹框提示 -->
<script type="text/javascript">
$(function () {
    $('.removeUser').click(function (event) {
        $('.zhezhao').css('display', 'block');
        $('#removeUse').fadeIn();
        $('#removeUse').attr("url",$(this).attr("href"));
        return false;
    });
   $('#yes').click(function () {
        $('.zhezhao').css('display', 'none');
        $('#removeUse').fadeOut();
        location= $('#removeUse').attr("url");
        return false;
    });
    $('#no').click(function () {
        $('.zhezhao').css('display', 'none');
        $('#removeUse').fadeOut();
        return false;
    });
});
</script>
</body>
</html>